package com.wangsd.web.face.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wangsd.web.face.entity.MerchantReceiver;
import com.wangsd.web.face.mapper.MerchantReceiverMapper;
import com.wangsd.web.face.service.MerchantReceiverService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author generator
 * @since 2019-09-17
 */
@Service
public class MerchantReceiverServiceImpl extends ServiceImpl<MerchantReceiverMapper, MerchantReceiver> implements MerchantReceiverService {

    @Resource
    MerchantReceiverMapper merchantReceiverMapper;

    @Override
    public Integer selectByMerchantAndReceiverId(Long merchantId, Long receiverId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("merchant_id", merchantId);
        queryWrapper.eq("receiver_id", receiverId);
        return merchantReceiverMapper.selectCount(queryWrapper);
    }

    @Override
    public void delMerchantReceiver(Long merchantId, Long receiverId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("merchant_id", merchantId);
        queryWrapper.eq("receiver_id", receiverId);
        merchantReceiverMapper.delete(queryWrapper);
    }
}
